import gradio as gr
from LLM2WeChatOfficialAccount import LLM2WeChatOfficialAccount


def greet(url):
    print(url)
    demo = LLM2WeChatOfficialAccount()
    docs = demo.getWeChatOfficialAccountMessage(url)
    text = demo.format_docs(docs)
    clean_docs = demo.getdocs(text,url)
    result = demo.refine_loop(clean_docs)
    print(result)
    return result

title = "大模型进行微信长文总结"
demo = gr.Interface(fn=greet, inputs="text", outputs=["text"], title=title)
# 获取所有输出组件
output_components = demo.output_components

# 设置新标题，可以为多个输出各自设置标题
output_components[0].label = "智能总结内容"
# output_components[1].label = "微信总结内容"

demo.launch(server_name="0.0.0.0", server_port=7860)

if __name__ == '__main__':
    demo.launch()